
#ifndef XDNS_DATA_IMPL_H
#define XDNS_DATA_IMPL_H

#include "xdns-data.h"
#include <vector>

class XdnsDataBlock;

class XdnsDataImpl : public XdnsData
{
public:
    friend class XdnsData;

    /* See xdns-data.h for description. */
    virtual XdnsError AppendData(unsigned char* buffer,
                                 size_t bufferSize);
    virtual XdnsError SetData(size_t position,
                              unsigned char* buffer,
                              size_t bufferSize);
    virtual size_t GetData(unsigned char* buffer,
                           size_t position,
                           size_t requestedSize) const;
    virtual size_t GetDataSize() const;
    virtual void Clear();
    virtual XdnsData* Clone() const;

private:
    XdnsDataImpl();
    virtual ~XdnsDataImpl();

    size_t m_totalSize;                     /*!< Total data size of all data blocks. */
    std::vector<XdnsDataBlock> m_blocks;    /*!< Data block items. */
};

class XdnsDataBlock
{
public:
    /*! XdnsDataBlock constructor.

        @param buffer Buffer to set. This function does not take
                      ownership of this buffer.
        @param bufferSize Number of bytes to set.
    */
    XdnsDataBlock(unsigned char* buffer,
                  size_t bufferSize);
    XdnsDataBlock(const XdnsDataBlock& anotherBlock);
    ~XdnsDataBlock();

    XdnsDataBlock& operator=(const XdnsDataBlock& anotherBlock);

    unsigned char* m_buffer;
    size_t m_bufferSize;
};

#endif  // XDNS_DATA_IMPL_H

